//
//  ClassContentTableViewCell.m
//  LiangYa_BObject
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 YuHao. All rights reserved.
//

#import "ClassContentTableViewCell.h"

@implementation ClassContentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.backV = [[UIView alloc] init];
//        _backV.clipsToBounds = YES;
//        _backV.layer.cornerRadius = 10;
//        _backV.backgroundColor = [UIColor colorWithRed:1.000 green:0.991 blue:0.925 alpha:1.000];
//        [self.contentView addSubview:_backV];
//        
//        self.imageV = [[UIImageView alloc] init];
//        _imageV.clipsToBounds = YES;
//        [self.backV addSubview:_imageV];
//        
//        self.brand_name = [[UILabel alloc] init];
//        _brand_name.textColor = [UIColor whiteColor];
//        _brand_name.textAlignment = NSTextAlignmentCenter;
//        _brand_name.font = [UIFont systemFontOfSize:15];
//        [self.imageV addSubview:_brand_name];
//        
//        self.style_name = [[UILabel alloc] init];
//        _style_name.textColor = [UIColor whiteColor];
//        _style_name.textAlignment = NSTextAlignmentCenter;
//        _style_name.font = [UIFont systemFontOfSize:15];
//        [self.imageV addSubview:_style_name];
//        
//        self.blackV = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
//        _blackV.alpha = 0.6;
//        [self.imageV addSubview:_blackV];
//        
//        self.goods_name = [[UILabel alloc] init];
//        _goods_name.textColor = [UIColor whiteColor];
//        _goods_name.font = [UIFont systemFontOfSize:14];
//        [self.blackV addSubview:_goods_name];
//        
//        self.red_title = [[UILabel alloc] init];
//        _red_title.numberOfLines = 0;
//        _red_title.font = [UIFont systemFontOfSize:15];
//        [self.backV addSubview:_red_title];
//        
//        self.soldNum = [[UILabel alloc] init];
//        _soldNum.textColor = [UIColor grayColor];
//        _soldNum.font = [UIFont systemFontOfSize:12];
//        _soldNum.textAlignment = NSTextAlignmentCenter;
//        [self.backV addSubview:_soldNum];
//        
//        self.price = [[UILabel alloc] init];
//        _price.textColor = [UIColor redColor];
//        _price.font = [UIFont systemFontOfSize:12];
//        _price.textAlignment = NSTextAlignmentCenter;
//        [self.backV addSubview:_price];
        
        // ================================================
        
        self.backImageV = [[UIImageView alloc] init];
        [self.contentView addSubview:_backImageV];
        
        self.blurV = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
        [self.backImageV addSubview:_blurV];
        
        self.buyBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        _buyBtn.backgroundColor = [UIColor whiteColor];
        [_buyBtn setTitle:@"购买" forState:UIControlStateNormal];
        _buyBtn.layer.cornerRadius = 10;
        _buyBtn.hidden = YES;
        [_buyBtn setTitleColor:[UIColor colorWithWhite:0.448 alpha:1.000] forState:UIControlStateNormal];
        [self.blurV addSubview:_buyBtn];
        
        self.red_title = [[UILabel alloc] init];
        _red_title.textColor = [UIColor whiteColor];
        _red_title.font = [UIFont systemFontOfSize:15];
        _red_title.minimumScaleFactor = 3;
        _red_title.numberOfLines = 0;
        [_red_title sizeToFit];
        [self.backImageV addSubview:_red_title];
        
        self.price = [[UILabel alloc] init];
        _price.textColor = [UIColor redColor];
        _price.font = [UIFont boldSystemFontOfSize:15];
        [self.backImageV addSubview:_price];
        
        self.soldNum = [[UILabel alloc] init];
        _soldNum.textColor = [UIColor whiteColor];
        _soldNum.font = [UIFont systemFontOfSize:15];
        [self.backImageV addSubview:_soldNum];
        
        self.imageV = [[UIImageView alloc] init];
        [self.contentView addSubview:_imageV];
        
//        self.blackV = [[UIView alloc] init];
//        _blackV.backgroundColor = [UIColor blackColor];
//        _blackV.alpha = 0.1;
//        [self.imageV addSubview:_blackV];
        
        self.goods_name = [[UILabel alloc] init];
        _goods_name.textColor = [UIColor whiteColor];
        _goods_name.font = [UIFont boldSystemFontOfSize:17];
        _goods_name.textAlignment = NSTextAlignmentCenter;
        [self.imageV addSubview:_goods_name];
        
        self.brand_name = [[UILabel alloc] init];
        _brand_name.textAlignment = NSTextAlignmentCenter;
        _brand_name.textColor = [UIColor whiteColor];
        _brand_name.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_brand_name];
        
        self.isLayout = YES;
        
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
//    _backV.frame = CGRectMake(10, 5, cellWidth - 20, cellHeight - 10);
//    _imageV.frame = CGRectMake(0, 0, _backV.frame.size.width, 220);
//    _brand_name.frame = CGRectMake(5, _imageV.frame.size.height - 50, 80, 25);
//    _style_name.frame = CGRectMake(85, _imageV.frame.size.height - 50, 80, 25);
//    _blackV.frame = CGRectMake(0, _imageV.frame.size.height - 25, _imageV.frame.size.width, 25);
//    _goods_name.frame = CGRectMake(5, 0, _blackV.frame.size.width - 10, 25);
//    _red_title.frame = CGRectMake(10, _imageV.frame.origin.y + _imageV.frame.size.height + 5, _backV.frame.size.width - 20, 0);
//    [_red_title sizeToFit];
//    _soldNum.frame = CGRectMake(_imageV.frame.size.width - 160, _red_title.frame.origin.y + _red_title.frame.size.height + 5, 80, 15);
//    _price.frame = CGRectMake(_imageV.frame.size.width - 80, _red_title.frame.origin.y + _red_title.frame.size.height + 5, 80, 15);
//    self.backgroundColor = [UIColor clearColor];

    // ==============================================
    if (self.isLayout == YES) {
        
        _backImageV.frame = self.contentView.frame;
        _blurV.frame = _backImageV.bounds;
        _buyBtn.frame = CGRectMake(cellWidth - 90, _backImageV.bounds.size.height - 300, 80, 40);
        _red_title.frame = CGRectMake(10, 60, cellWidth - 20, _blurV.frame.size.height - 100);
        _price.frame = CGRectMake(cellWidth - 170, cellHeight - 30, 80, 20);
        _soldNum.frame = CGRectMake(cellHeight - 90, cellHeight - 30, 80, 20);
        _imageV.frame = self.bounds;
//        _blackV.frame = _imageV.bounds;
        _goods_name.frame = CGRectMake(0, 65, cellWidth, 25);
        _brand_name.frame = CGRectMake(0, 90, cellWidth, 25);
    }
    
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
